﻿package plugin.juezhan.ui
{
    import flash.events.*;
    import manager.*;
    import morn.core.components.*;
    import morn.core.handlers.*;
    import plugin.juezhan.model.*;
    import pluginfw.nio.*;
    import uiresource.juezhan.*;
    import view.mornExtends.*;
    import view.uilt.*;

    public class RankRewardCtrl extends SanviewUI
    {
        private var arr:Array;

        public function RankRewardCtrl()
        {
            this.arr = [];
            return;
        }// end function

        override protected function initializeView() : void
        {
            var _loc_3:Object = null;
            var _loc_4:Array = null;
            super.initializeView();
            var _loc_1:* = ConfigDictionary.data.tianguanrankreward;
            var _loc_2:int = 1;
            while (_loc_2 <= 5)
            {
                
                _loc_3 = _loc_1[_loc_2];
                if (_loc_3)
                {
                    this.arr.push(ItemUilt.getBoxArr(_loc_3.boxid));
                    _loc_4 = (_loc_3.rank as String).split("#");
                    if (_loc_4[0] == _loc_4[1])
                    {
                        (this["rank" + _loc_2] as Label).text = "第" + _loc_4[0] + "名";
                    }
                    else
                    {
                        (this["rank" + _loc_2] as Label).text = "第" + _loc_4[0] + "名至第" + _loc_4[1] + "名";
                    }
                }
                _loc_2++;
            }
            this.arr.push(_loc_1[6]);
            list1.renderHandler = new Handler(this.itemHandler1);
            list1.array = this.arr[0];
            list2.renderHandler = new Handler(this.itemHandler2);
            list2.array = this.arr[1];
            list3.renderHandler = new Handler(this.itemHandler3);
            list3.array = this.arr[2];
            list4.renderHandler = new Handler(this.itemHandler4);
            list4.array = this.arr[3];
            list5.renderHandler = new Handler(this.itemHandler5);
            list5.array = this.arr[4];
            dangqianList.renderHandler = new Handler(this.itemHandler);
            lingquBtn.addEventListener(MouseEvent.CLICK, this.clickHandler);
            return;
        }// end function

        protected function clickHandler(event:MouseEvent) : void
        {
            var _loc_2:* = new Output();
            PluginManager.instance.sendToBufferServer("juezhan", CMDJueZhan.ReqTGRankRewards, _loc_2);
            return;
        }// end function

        public function showreward(param1:int) : void
        {
            var _loc_5:int = 0;
            var _loc_6:int = 0;
            var _loc_7:Array = null;
            var _loc_2:* = ConfigDictionary.data.tianguanrankreward;
            var _loc_3:Array = [];
            var _loc_4:* = _loc_2[6];
            if (param1 == 0)
            {
                dangqianList.array = ItemUilt.getBoxArr(_loc_4.boxid);
            }
            else
            {
                _loc_5 = 0;
                _loc_6 = 1;
                while (_loc_6 <= 5)
                {
                    
                    _loc_4 = _loc_2[_loc_6];
                    if (_loc_4)
                    {
                        _loc_7 = (_loc_4.rank as String).split("#");
                        if (_loc_7[0] == _loc_7[1] && param1 == _loc_7[0])
                        {
                            _loc_5 = _loc_6;
                            dangqianList.array = ItemUilt.getBoxArr(_loc_4.boxid);
                            break;
                        }
                        else if (param1 >= _loc_7[0] && param1 < _loc_7[1])
                        {
                            _loc_5 = _loc_6;
                            dangqianList.array = ItemUilt.getBoxArr(_loc_4.boxid);
                            break;
                        }
                    }
                    _loc_6++;
                }
            }
            return;
        }// end function

        private function itemHandler(param1:Component, param2:int) : void
        {
            if (param2 < dangqianList.length)
            {
                (param1.getChildByName("item") as FlashItem).data = param1.dataSource;
            }
            return;
        }// end function

        private function itemHandler1(param1:Component, param2:int) : void
        {
            if (param2 < list1.length)
            {
                (param1.getChildByName("item") as FlashItem).data = param1.dataSource;
            }
            return;
        }// end function

        private function itemHandler2(param1:Component, param2:int) : void
        {
            if (param2 < list2.length)
            {
                (param1.getChildByName("item") as FlashItem).data = param1.dataSource;
            }
            return;
        }// end function

        private function itemHandler3(param1:Component, param2:int) : void
        {
            if (param2 < list3.length)
            {
                (param1.getChildByName("item") as FlashItem).data = param1.dataSource;
            }
            return;
        }// end function

        private function itemHandler4(param1:Component, param2:int) : void
        {
            if (param2 < list4.length)
            {
                (param1.getChildByName("item") as FlashItem).data = param1.dataSource;
            }
            return;
        }// end function

        private function itemHandler5(param1:Component, param2:int) : void
        {
            if (param2 < list5.length)
            {
                (param1.getChildByName("item") as FlashItem).data = param1.dataSource;
            }
            return;
        }// end function

    }
}
